<template>
  <div class="app">
    <button @click="getNews">点我获取头条新闻</button>
    <button @click="getInfo">点我获取分类信息</button>
    <button @click="getBaiduNews">点我获取百度新闻</button>
  </div>
</template>

<script>
  import axios from 'axios'
  export default {
    name:'App',
    methods: {
      getNews(){
        let x = axios.get('/api1/hot-event/hot-board/?origin=toutiao_pc')
        x.then(
          (response)=>{console.log('成功',response.data.data)},
          (error)=>{console.log('失败',error)}
        )
      },
      getInfo(){
        let result = axios.get('http://sph-h5-api.atguigu.cn/api/product/getBaseCategoryList')
        result.then(
          response => {console.log('成功',response.data.data)},
          error => {console.log('失败',error)}
        )
      },
      getBaiduNews(){
        let result = axios.get('/api2/widget?id=LocalNews&ajax=json')
        result.then(
          response => {console.log('成功',response.data.data.LocalNews.data.rows.first)},
          error => {console.log('失败',error)}
        )
      }
    },
  }
</script>

<style scoped>
  .app{
    background-color: #ddd;
    border-radius: 10px;
    padding: 10px;
    box-shadow: 0 0 10px;
  }
</style>